import request from '@/config/axios'
import * as classifyApi from "@/api/classify";
import * as labelApi from "@/api/infra/label";

/**
 * 上传分片
 * @param data
 */
export const uploadChunk = (data) => {
  return request.upload({ url: '/video/uploadChunk', data: data })
}

/**
 * 不分片直接上传文件
 * @param data
 */
export const upload = (data) => {
  return request.upload({ url: '/video/upload', data: data })
}

/**
 * 保存
 * @param params
 */
export const save = async (params: PageParam) => {
  return await request.post({ url: '/video/save', data: params })
}

// 删除
export const deleted = async (ids) => {
  return await request.delete({ url: '/video/delete', data: ids })
}

// 查询视频库列表
export const page = async (params: PageParam) => {
  return await request.get({ url: '/video/page', params })
}

export const toAudit = async (params: PageParam) => {
  return await request.post({ url: '/video/toAudit', data: params })
}

export const audit = async (params: PageParam) => {
  return await request.post({ url: '/video/audit', data: params })
}

export const back = async (params: PageParam) => {
  return await request.post({ url: '/video/back', data: params })
}

export const unRelease = async (ids) => {
  return await request.post({ url: '/video/un/release', data: ids })
}

export const selectOne = async (id) => {
  return await request.get({ url: '/video/one/' + id })
}

export const selectDeleted = async (id, deleted) => {
  return await request.get({ url: '/video/one/' + id + '/' + deleted })
}

export const merge = async (uuid, chunkTotal, size, ext) => {
  return await request.get({
    url:
      '/video/merge?uuid=' +
      uuid +
      '&chunkTotal=' +
      chunkTotal +
      '&fileSize=' +
      size +
      '&ext=' +
      ext
  })
}

// 回收站删除列表查询
export const recycle = async (params: PageParam) => {
  return await request.get({ url: '/video/recycle', params })
}

// 回收站还原
export const revert = async (ids) => {
  return await request.post({ url: '/video/revert', data: ids })
}

// 删除回收站数据
export const deleteByIds = async (ids) => {
  return await request.delete({ url: '/video/deleteByIds', data: ids })
}

//查询视频分类
export const getVideoClassify = async () => {
  return await classifyApi.classifyTree('video')
}

//查询视频分类
export const getVideoLabel = async () => {
  return await labelApi.labelTree('video')
}

//发布
export const issue = async (ids) => {
  return await request.post({ url: '/video/issue', data: ids })
}
